<h2>Schedule</h2>

<% if current_volunteer.any_admin? %>
<div style="text-align: right;">
<%= form_tag("/locations/new", :method => "get") do %>
New Donor For <%= select_tag(:region_id, options_for_select(@my_admin_regions.collect{ |r| [r.name,r.id] })) %>
<%= hidden_field_tag :is_donor, true %>
<%= submit_tag("Go") %>
<% end %>
</div>
<% end %>

<% if current_volunteer.any_admin? %>
<div style="text-align: right;">
<%= form_tag("/locations/new", :method => "get") do %>
New Recipient For <%= select_tag(:region_id, options_for_select(@my_admin_regions.collect{ |r| [r.name,r.id] })) %>
<%= hidden_field_tag :is_donor, false %>
<%= submit_tag("Go") %>
<% end %>
</div>
<% end %>

<% if @locations.length == 0 %>
<p> 
No locations.
</p>
<% else %>
<table id="my_schedule_table">
  <thead>
  <tr>
    <th> Name </th>
    <th> Address </th>
    <th> Contact Info </th>
    <th> Hours </th>
    <th> Type </th>
    <th> Notes </th>
    <% if current_volunteer.any_admin? %>
    <th> Admin Notes </th>
    <th> Link </th>
    <% end %>
  </tr>
  </thead>
  <tbody>
  <%
  @locations.each do |loc|
  %>
  <tr>
    <td> <%= loc.name.nil? ? loc.name : (link_to loc.name, loc) %> <% unless loc.website.nil? %><%= link_to "(website)", loc.website %><% end %></td>
    <td> <%= loc.address.gsub("\n","<br>").html_safe unless loc.address.nil? %></td>
    <td> <%= loc.contact.gsub("\n","<br>").html_safe unless loc.contact.nil? %> </td>
    <td> <%= loc.hours.gsub("\n","<br>").html_safe unless loc.hours.nil? %> </td>
    <td> <%= loc.is_donor ? loc.donor_type : loc.recip_category %>
    <td><%= word_wrap(loc.public_notes,:line_width => 20).gsub("\n","<br>").html_safe unless loc.public_notes.nil? %></td>
    <% if current_volunteer.any_admin? %>
    <td><%= word_wrap(loc.admin_notes,:line_width => 20).gsub("\n","<br>").html_safe unless loc.admin_notes.nil? or !(current_volunteer.any_admin?) %></td>
    <td> <% unless loc.receipt_key.nil?%>
           <%= link_to 'hud', "/locations/hud?id=#{loc.id}&key=#{loc.receipt_key}" %><br>
         <% end %>
         <%= link_to 'edit', :controller => "locations", :action => "edit", :id => loc %><br>
         <%= link_to "delete", loc, :confirm => "Are you sure?", :method => :delete %> </td>
    <% end %>
  </tr>
  <% end %>
  </tbody>
</table>
<% end %>
